<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<input type="text" v-model="title"/>
		<button @click="sendfn">发布</button>
		<view v-for="(item,index) in arr" :key="item.id">
			{{item.id}}:{{item.title}}<button @click="delfn(index)">删除</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				arr:[
					{id:1,title:'aaa'},
					{id:2,title:'bbb'},
					{id:3,title:'ccc'},
				],
				nextId: 4,
			}
		},
		onLoad() {

		},
		methods: {
		sendfn(){
			if(!this.title.trim()){
				uni.showToast({title: '请输入内容',});
				return
			};
			this.arr.push({id: this.nextId,  
						title: this.title 
							});
							this.nextId++;
							this.title = '';
		},
		delfn(index){
			this.arr.splice(index,1)
		}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
